-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(material/button): combine MatButton and MatAnchor #30492
base: main
Are you sure you want to change the base?
Conversation
e1f2211
to
074ed69
Compare
@@ -153,14 +162,28 @@ export class MatButtonBase implements AfterViewInit, OnDestroy { | |||
@Input({transform: booleanAttribute}) | |||
disabledInteractive: boolean; | |||
|
|||
/** Tab index for the button. */ | |||
@Input({transform: transformTabIndex}) | |||
tabIndex: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be the deprecated one instead? I think most of our components that take a tabindex use the all-lowercase spelling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we use tabIndex
across a bunch of other components as well. I think it's because the native property is also called tabIndex
, see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex
const classList = (element as HTMLElement).classList; | ||
|
||
this._isAnchor = element.tagName === 'A'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should .toUpperCase()
this to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be guaranteed to be uppercase. The only time tag names preserve their case is in SVG.
Currently we have two directives for each button variant: `MatButton` which applies to `button` elements and `MatButtonAnchor` which applies to anchors. This is problematic in a couple of ways: 1. The styles, which can be non-trivial, are duplicated if both classes are used. 2. Users have to think about which class they're importing. These changes combine the two classes to resolve the issues and simplify our setup. BREAKING CHANGE: `tabindex` values set as `[attr.tabindex]` set on a Material button might not work as expected. Use `tabindex` for static values, or `[tabindex]`/`[tabIndex]` for dynamic ones.
074ed69
to
166d46d
Compare
Currently we have two directives for each button variant:
MatButton
which applies tobutton
elements andMatButtonAnchor
which applies to anchors.This is problematic in a couple of ways:
These changes combine the two classes to resolve the issues and simplify our setup.
BREAKING CHANGE:
tabindex
values set as[attr.tabindex]
set on a Material button might not work as expected. Usetabindex
for static values, or[tabindex]
/[tabIndex]
for dynamic ones.